<?php
namespace app\admin\validate;

use think\Validate;
use think\Db;
class TeacherValidate extends Validate
{
	protected $rule = [
        ['name', 'require', '姓名不能为空'],
        ['name', 'chs', '姓名只能填写汉字'],
        ['phone', 'require', '手机号不能为空'],
        ['phone', 'is_phone', '手机号格式不正确'],
        ['email', 'email', '邮箱格式不正确'],
        ['school_id', 'school', '请选择学校/该学校不存在'],

    ];

    protected function is_phone($value){
		if(preg_match("/^1[34578]\d{9}$/", $value)){
			return true;
		}else{
			return false;
		}
	}
	protected function school($value){
		if(DB::name('school_specialty')->where('id',$value)->find()){
			return true;
		}else{
			return false;
		}
	}
}